package day01;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo2 {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.jdbc.Driver");
        Connection conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/my01","root","1234");
        Statement st=conn.createStatement();
        //增删改均使用executeUpdate,sql语句要完全正确
        int a=st.executeUpdate("insert into student values(null,'李四',23)");
//        int b=st.executeUpdate("update student set age=24 where name='李四'");
//        int c=st.executeUpdate("delete from student where id=2");
        //返回值代表操作成功的行数
        System.out.println("插入了"+a+"条数据");
        st.close();
        conn.close();
    }
}
